function [gam,b] = mkm(V,Y,C)

if (nargin < 2)
    error('Not enough arguments!');
end

[n,s] = size(V);
l = size(Y,1);
P = repmat(Y,1,s).*V;

if (nargin == 2)
    disp('Training hard-margin mkm...');
    cvx_begin sdp quiet
    cvx_solver sedumi
    cvx_solver_settings('maxiter',500);
    variable t
    variable gam(s,1)
    variable M(s,s) symmetric
    variable b
    minimize (t);
    [M gam; gam' t] >= 0;
    P*gam+b*Y-ones(l,1) >= 0;
    cvx_end
    fprintf('Status:\t%s\n',cvx_status);
    fprintf('Value:\t%f\n',cvx_optval);
    fprintf('Time:\t%f\n',cvx_cputime);
    fprintf('Iters:\t%d\n',cvx_slvitr);
    fprintf('\n');
else
    disp('Training soft-margin svm...');
    cvx_begin sdp quiet
    cvx_solver sedumi
    cvx_solver_settings('maxiter',500);
    variable t
    variable gam(s,1)
    variable del(l,1) nonnegative
    variable M(s,s) symmetric
    variable b
    minimize (t+2*C*sum(del));
    [M gam; gam' t] >= 0;
    P*gam+b*Y-ones(l,1)+del >= 0;
    cvx_end
    fprintf('Status:\t%s\n',cvx_status);
    fprintf('Value:\t%f\n',cvx_optval);
    fprintf('Time:\t%f\n',cvx_cputime);
    fprintf('Iters:\t%d\n',cvx_slvitr);
    fprintf('\n');
end
end